﻿using STHPMS1.DAL.D_Core;
using System.Data;
using ServiceStack.OrmLite;
using STHPMS1.ICore.I_Entity.Stmpms1;
using STHPMS1.Common.C_Entity.Stmpms1;
using STHPMS1.ICore.I_DAL.Repository;
using System.Collections.Generic;
namespace STHPMS1.DAL.D_Repository
{
    public class Df_Seclass_ProjRepository : DalBase, IDf_Seclass_ProjRepository
    {
        /// <summary>
        /// 根据条件获取长度：资金受限条件养护方案表
        /// </summary>
        /// <param name="anni_name">资金模型名称</param>
        /// <param name="analy_year">分析年度</param>
        /// <param name="rd_class">技术等级</param>
        /// <param name="segid_main">养护类型</param>
        /// <returns></returns>
        public double GetRoadLenght(string anni_name, string analy_year, int rd_class, int segid_main)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select sum(ENDMP-BEGINMP) from DF_FUNLIM_PROJ where ANNI_NAME='" + anni_name + "' and ANALY_YEAR='" + analy_year + "'  and RD_CLASS=" + rd_class + " and SEGID_MAIN=" + segid_main + "";
            return conn.Scalar<double>(strsql);
        }

        /// <summary>
        /// 根据条件获取路段养护费用：资金受限条件养护方案表
        /// </summary>
        /// <param name="anni_name">资金模型名称</param>
        /// <param name="analy_year">分析年度</param>
        /// <param name="rd_class">技术等级</param>
        /// <param name="segid_main">养护类型</param>
        /// <returns></returns>
        public double GetSegid_MainCOST(string anni_name, string analy_year, int rd_class, int segid_main)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select sum(SEGID_MAINCOST) from DF_FUNLIM_PROJ where ANNI_NAME='" + anni_name + "' and RD_CLASS=" + rd_class + " and SEGID_MAIN=" + segid_main + "";
            return conn.Scalar<double>(strsql);

        }

        /// <summary>
        /// 获取该资金模型下的所有技术等级：资金受限条件养护方案表
        /// </summary>
        /// <param name="anni_name">资金模型名称</param>
        /// <returns></returns>
        public List<int> GetRD_ClassList(string anni_name)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select distinct RD_CLASS from DF_FUNLIM_PROJ where ANNI_NAME='" + anni_name + "'";
            return conn.Column<int>(strsql);
        }
    }
}
